import java.util.Scanner;

/**
 * Created With IntelliJ IDEA
 * Description:牛客网:首页 > 试题广场 > 星际密码
 * <a href="https://www.nowcoder.com/questionTerminal/34f17d5f2a8240bea661a23ec095a062">...</a>
 * User: DELL
 * Data: 2023-04-17
 * Time: 16:57
 */

//根据观察,矩阵左上角的数字满足斐波那契数列
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int[] keyword = new int[10001];
        //初始化 keyword 数组
        keyword[0] = 1;
        keyword[1] = 1;
        for (int i = 2; i < 10001; i++) {
            keyword[i] = (keyword[i-1] + keyword[i-2]) % 10000;
        }
        //多组输入
        while(scanner.hasNext()) {
            int n = scanner.nextInt();
            while (n-- != 0) {
                int num = scanner.nextInt();
                System.out.printf("%04d", keyword[num]);
            }
            System.out.println();
        }
    }
}
